package com.nahan.secondapplication.Custombulletframe;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.nahan.secondapplication.R;

public class CustomPopwindowsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_popwindows);


        findViewById(R.id.pop_windows).setOnClickListener(v ->
        {
            CustomPopWindow mPopwindow = new CustomPopWindow(CustomPopwindowsActivity.this, itemsOnClick);
            mPopwindow.showAsDropDown(v,
                    Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        });
    }

    //为弹出窗口实现监听类
    private View.OnClickListener itemsOnClick = new View.OnClickListener() {

        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.ll_wechat_share:
                    Toast.makeText(CustomPopwindowsActivity.this, "微信好友", Toast.LENGTH_SHORT).show();
                    break;
                case R.id.ll_wechat_zone:
                    Toast.makeText(CustomPopwindowsActivity.this, "朋友圈", Toast.LENGTH_SHORT).show();
                    break;
                case R.id.ll_qq_share:
                    Toast.makeText(CustomPopwindowsActivity.this, "QQ好友", Toast.LENGTH_SHORT).show();
                    break;
                case R.id.ll_qq_zone:
                    Toast.makeText(CustomPopwindowsActivity.this, "QQ空间", Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;
            }
        }

    };
}